package cn03;

import java.util.ArrayList;
import java.util.Scanner;

public class test {
    public static void main(String[] args) {
        ArrayList<student> array = new ArrayList<>();

        addstudent(array);
        addstudent(array);
        addstudent(array);

        for (int i = 0; i < array.size(); i++) {
            student s = array.get(i);
            System.out.println(s.getName() + "," + s.getAge());
        }
    }

    public static void addstudent(ArrayList<student> array) {
        Scanner sc = new Scanner(System.in);

        System.out.println("请输入学生姓名：");
        String name = sc.nextLine();
        System.out.println("请输入学生年龄");
        String age = sc.nextLine();

        student s = new student();
        s.setName(name);
        s.setAge(age);

        array.add(s);
    }
}
